package com.ruoyi.civil.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.civil.domain.CivilEnginneeringAllMaintenance;
import com.ruoyi.civil.service.ICivilEnginneeringAllMaintenanceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 养护计划方案Controller
 * 
 * @author ruoyi
 * @date 2022-05-11
 */
@RestController
@RequestMapping("/civil/allmaintenance")
public class CivilEnginneeringAllMaintenanceController extends BaseController
{
    @Autowired
    private ICivilEnginneeringAllMaintenanceService civilEnginneeringAllMaintenanceService;

    /**
     * 查询养护计划方案列表
     */
    @PreAuthorize("@ss.hasPermi('civil:allmaintenance:list')")
    @GetMapping("/list")
    public TableDataInfo list(CivilEnginneeringAllMaintenance civilEnginneeringAllMaintenance)
    {
        startPage();
        List<CivilEnginneeringAllMaintenance> list = civilEnginneeringAllMaintenanceService.selectCivilEnginneeringAllMaintenanceList(civilEnginneeringAllMaintenance);
        return getDataTable(list);
    }

    /**
     * 导出养护计划方案列表
     */
    @PreAuthorize("@ss.hasPermi('civil:allmaintenance:export')")
    @Log(title = "养护计划方案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CivilEnginneeringAllMaintenance civilEnginneeringAllMaintenance)
    {
        List<CivilEnginneeringAllMaintenance> list = civilEnginneeringAllMaintenanceService.selectCivilEnginneeringAllMaintenanceList(civilEnginneeringAllMaintenance);
        ExcelUtil<CivilEnginneeringAllMaintenance> util = new ExcelUtil<CivilEnginneeringAllMaintenance>(CivilEnginneeringAllMaintenance.class);
        util.exportExcel(response, list, "养护计划方案数据");
    }

    /**
     * 获取养护计划方案详细信息
     */
    @PreAuthorize("@ss.hasPermi('civil:allmaintenance:query')")
    @GetMapping(value = "/{allMaintenanceId}")
    public AjaxResult getInfo(@PathVariable("allMaintenanceId") Long allMaintenanceId)
    {
        return AjaxResult.success(civilEnginneeringAllMaintenanceService.selectCivilEnginneeringAllMaintenanceByAllMaintenanceId(allMaintenanceId));
    }

    /**
     * 新增养护计划方案
     */
    @PreAuthorize("@ss.hasPermi('civil:allmaintenance:add')")
    @Log(title = "养护计划方案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CivilEnginneeringAllMaintenance civilEnginneeringAllMaintenance)
    {
        return toAjax(civilEnginneeringAllMaintenanceService.insertCivilEnginneeringAllMaintenance(civilEnginneeringAllMaintenance));
    }

    /**
     * 修改养护计划方案
     */
    @PreAuthorize("@ss.hasPermi('civil:allmaintenance:edit')")
    @Log(title = "养护计划方案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CivilEnginneeringAllMaintenance civilEnginneeringAllMaintenance)
    {
        return toAjax(civilEnginneeringAllMaintenanceService.updateCivilEnginneeringAllMaintenance(civilEnginneeringAllMaintenance));
    }

    /**
     * 删除养护计划方案
     */
    @PreAuthorize("@ss.hasPermi('civil:allmaintenance:remove')")
    @Log(title = "养护计划方案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{allMaintenanceIds}")
    public AjaxResult remove(@PathVariable Long[] allMaintenanceIds)
    {
        return toAjax(civilEnginneeringAllMaintenanceService.deleteCivilEnginneeringAllMaintenanceByAllMaintenanceIds(allMaintenanceIds));
    }
}
